﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Web.Security;

namespace OnlineBusTicket
{
    public partial class Buslist : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
                con.Open();
                SqlDataAdapter da = new SqlDataAdapter("SELECT [BusListId],[TotalNumberOfSeats] as [Total seats],[BusCategory],[DeparturePlace],[ArrivePlace],CONVERT(varchar(20),[StartDate],103) as StartDate,CONVERT(varchar(20),[EndDate],103) as EndDate,[Time],[Price]  FROM Buslist  ", con);
                DataSet ds = new DataSet();
                da.Fill(ds, "Buslist");
                GridView1.DataSource = ds;
                GridView1.DataBind();
            }
        }

        protected void btnUpdateTour_Click(object sender, EventArgs e)
        {
            Response.Redirect("UpdateTour.aspx");
        }

        protected void btnDelTour_Click(object sender, EventArgs e)
        {
            Response.Redirect("DelTour.aspx");
        }

        //protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    //  int BusID = Int32.Parse(Session["BusListID"].ToString());

        //    //luu buslistid o cell thu 1 vao session "BusListId";
        //    string userName = HttpContext.Current.User.Identity.Name;
        //    if (userName == "")
        //    {
        //        Response.Redirect("Login.aspx");
        //    }
        //    else
        //    {
        //        Session["BusListId"] = GridView1.SelectedRow.Cells[1].Text;
        //        Response.Redirect("BookBus.aspx");
        //    }

        //}

        
    }
}